<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
        .note-editable {
            height: 150px
        }

        .radio-inline input[type=radio] {
            margin-top: 4px
        }
    </style>
</head>

<body style="color:#333;padding:3px;">
<!-- 标题 -->
<div class="page-heade">
    <h2 class="title_color text-center">添加模板</h2>
</div>
<!-- 标题 -->
<div class="form-inline">
    <form action="">
        <table class="row-margin-top tab-content table-bordered table text-center" border="1">
            <tr>
                <td style="width: 140px;min-width: 140px"><label for="" class="form-label">作者：</label></td>
                <td class="text-left">{:db('employee')->where('id',session('employee_id'))->value('em_name')}</td>
            </tr>
            <tr>
                <td style="width: 140px;min-width: 140px"><label for="" class="form-label">是否公用模板<span class="colorRed">*</span>：</label>
                </td>
                <td class="text-left">
                    <label class="radio-inline">
                        <input type="radio" name="ispublic" id="inlineRadio5" value="0" {if isset($data)&&$data.ispublic==0}checked{/if}>是
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="ispublic" id="inlineRadio6" value="1" {if (isset($data)&&$data.ispublic==1)||!isset($data)}checked{/if}>否
                    </label>
                </td>
            </tr>
            <tr>
                <td style="width: 140px;min-width: 140px"><label for="" class="form-label">模板标题<span
                        class="colorRed">*</span>：</label></td>
                <td class="text-left"><input type="text" name="title" value="{:isset($data)?$data.title:''}" class="form-control"></td>
            </tr>
            <tr>
                <td colspan="2"><label for="" class="form-label">模板内容如下<span class="colorRed">*</span>：</label></td>
            </tr>
            <tr>
                <td colspan="2" class="text-left">
                    <div class="ibox float-e-margins" style="margin-bottom: 0">
                        <div class="ibox-content no-padding">

                            <div class="summernote">
                                {:isset($data)?$data.brief:''}
                            </div>

                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2" class="text-left">
                    温馨提示：本编辑器不支持复杂表单提交，复杂表单请以附件形式提交
                </td>
            </tr>
        </table>
        <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0">
            <input type="submit" class="btn btn-success" value="保存为草稿" id="baocun">
            <input type="submit" class="btn btn-info" value="保存并提交流程" >
            <input type="button" class="btn btn-warning" value="返回" onclick="back()">
        </div>
    </form>
</div>
<!-- 全局js -->
{include file="Public/footer"}
<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote-zh-CN.js"></script>
<script>
    $(document).ready(function () {

        $('.summernote').summernote({
            lang: 'zh-CN'
        });
    });

    function back() {
        history.go(-1)
    }

    //保存
    $('#baocun').on('click',function () {
        var ispublic = $('[name=ispublic]:checked').val()
        var title = $('[name=title]').val()
        var brief = $('.summernote').code()

        $.post('',{title:title,ispublic:ispublic,brief:brief},function(data) {
            if(data.success){
                swal({
                    title:data.msg,
                    type:'success'
                },function () {
                    location.href = '{:url("index")}'
                })
            }else
                swal(data.msg, "", "error");
        },'json')
        return false;
    })
</script>
</body>

</html>
